#pragma once
#include <windows.h>
#include <memory>

#include "tstring.h"

#pragma warning(push)
#pragma warning(disable: 4996)
#include <boost/gil/typedefs.hpp>
#include <boost/gil/image.hpp>
#pragma warning(pop)

#include "ImageIOHelper.h"
#include "ImageIOExceptions.h"

using namespace boost::gil;

class CImageSplitter
{
	rgb8_image_t* m_SourceImage;
	CImageIOHelper m_ImageIOHelper;

	SIZE m_NewSize;
	SIZE m_PieceSize;
	
	bool CheckSizes();
	int GetHorisontalPieceCount();
	int GetVerticalPieceCount();
	void GetPiece(int Index, rgb8_image_t& Piece);
	void GetSourcePieceSize(int Index, SIZE& PieceSize);
public:
	CImageSplitter();
	~CImageSplitter();

	void OpenImage(const tstring& PathToFile);
	void Close();

	LONG GetImageHeightInPixels();
	LONG GetImageWidthInPixels();

	void ResizeImage(LONG NewWidth, LONG NewHeight);
	void ResizeImage(FLOAT Scale);
	void SetJPEGQuailty(int Quality);
	void SetOutputImageType(ImageType_t ImageType);

	void SplitImage(LONG PieceWidth, LONG PieceHeight);
	int GetPieceCount();
	void GetPiece(int Index, LPCTSTR PathToFile);
	void GetPieceSize(int Index, SIZE& PieceSize);
};